package com.demo.util;

import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import net.sf.json.JSONObject;

public class CommonUtil {

	public static void sendMessage(Map<String,Object> result){
		HttpServletResponse response =ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter writer =null;
	    	try{
	    		JSONObject json =JSONObject.fromObject(result);
	    		writer =response.getWriter();
	    		writer.write(json.toString());
	    	}catch(Exception e){
	    		e.printStackTrace();
	    	}finally{
	    		if(writer !=null){
	    			writer.close();
	    		}
	    	}
	}
	
}
